home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10368 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  50 lines

  1. Newsgroups: comp.lang.c
  2. Path: news.sprintlink.net!news1!ts02-and-07
  3. From: dlmiller@iquest.net (Doug & Rose Miller)
  4. Subject: Re: Help !!!!! on 'strstr"
  5. X-Nntp-Posting-Host: ts02-and-07.iquest.net
  6. Message-ID: <DoE30t.G5u@iquest.net>
  7. Sender: news@iquest.net (News Admin)
  8. Organization: IQuest Network Services
  9. X-Newsreader: News Xpress Version 1.0 Beta #2.1
  10. References: <314703FF.4045@msmail.st.stems.com>
  11. Date: Sun, 17 Mar 1996 01:57:39 GMT
  12.  
  13. kim hai <Kim_Hai.Ng@msmail.st.stems.com> wrote:
  14. +Help !!!!!
  15. +
  16. +Problem :
  17. +    I need to locate a string within another string, and the process
  18. +must be case insensitive. As far as I know, strstr() only locates the
  19. +exact match and is case sensitive.
  20. +    Does anyone konw of any functions that could allow me to locate
  21. +substrings and is case insensitive ?
  22. +
  23. +Eg.
  24. +case 1:
  25. +    string1 = "abc"
  26. +    string2 = "abcdef"
  27. +case 2:
  28. +    string2 = "Abcdef"
  29. +case 3:
  30. +    string3 = "aBcdef"
  31. +case 4:
  32. +    string4 = "abCdef"
  33. +.....
  34. +....
  35. +...
  36. +
  37. +Is taking care of all the combinations ( = 8) in string1 the only
  38. +solution ? I'm working on Unix platform.
  39. +
  40. +Thankx
  41. +
  42. +<hai>
  43. +
  44. Use strupr() on both strings -- to insure they are both the same case -- before using strstr().
  45. Of course, strlwr() would work also.
  46.  
  47. Perhaps you should copy both strings to temporary areas and use strupr() on the temps,
  48. because it does not merely return the case-shifted string, it actually case-shifts the original.
  49.  
  50.